<template>
  <div class="full-box shadow-box padding-box">
    <OperateCommon :showSearch="true" @search="initData">
      <template #condition>
        <div class="condition-item">
          <el-date-picker
            style="width: 130px"
            v-model="queryParams.plan_year"
            type="year"
            value-format="yyyy"
            placeholder="申报年份"
            clearable
          >
          </el-date-picker>
        </div>
        <div class="condition-item">
          <el-select
            style="width: 150px"
            v-model="queryParams.industry_type"
            value-key=""
          >
            <el-option
              v-for="item in industryOptions"
              :key="item.id"
              :label="item.dict_value"
              :value="item.id"
            ></el-option>
          </el-select>
        </div>
        <div class="condition-item">
          <el-input
            v-model="queryParams.project_name"
            placeholder="按项目名称查询"
            clearable
          ></el-input>
        </div>
        <div class="condition-item">
          <el-input
            v-model="queryParams.create_user_name"
            placeholder="上报人"
            clearable
          ></el-input>
        </div>
      </template>
      <template #operate>
        <el-button icon="el-icon-plus" type="primary" @click="handleDeclare"
          >项目申报</el-button
        >
      </template>
    </OperateCommon>
    <div class="table-wrapper">
      <BaseTable
        :columns="columns"
        :showSort="true"
        :tableData="tableData"
        :pages="{
          show: true,
          count: count,
        }"
        :operate="{
          show: true,
          width: 200,
        }"
        @pagination="pageChange"
      >
        <template #operate="{ current }">
          <el-button type="primary" size="mini" @click="linkWhere(current.row)"
            >详情</el-button
          >
          <!-- <el-button
            type="danger"
            size="mini"
            @click="deleteConfirm(current.row.id)"
            >删除</el-button
          > -->
        </template>
      </BaseTable>
    </div>
  </div>
</template>

<script>
import BaseTable from "@/components/Common/BaseTable.vue";
import OperateCommon from "@/components/Common/OperateCommon.vue";
import LinkTo from "@/mixins/LinkTo";
import commonList from "@/mixins/commonList";
import m_industry from "@/mixins/industry";
import { getIndustry, getYearPlanList } from "@/api/YearPlan/Index";
export default {
  mixins: [LinkTo, commonList, m_industry],
  components: { BaseTable, OperateCommon },
  data() {
    return {
      columns: columns,
      tableData: [],
      count: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        project_name: "",
        status: "",
        plan_year: "",
        industry_type: "",
        create_user_name: "",
      },
    };
  },
  methods: {
    handleDeclare() {
      this.linkTo(`/yearplan/declare/0/0`);
    },
    initData() {
      getYearPlanList(this.queryParams).then((res) => {
        if (res.code == 0) {
          this.tableData = res.data;
          this.count = res.num;
        }
      });
    },
    pageChange(val) {
      this.queryParams.pageNum = val.pageNum;
      this.queryParams.pageSize = val.pageSize;
      this.initData();
    },
    linkWhere(item) {
      this.linkTo(`/yearplan/declare/${item.id}/0`);
    },
  },
  created() {
    this.initData();
  },
};

const columns = [
  {
    prop: "plan_year",
    label: "申报年份",
    width: "100",
    minWidth: "",
    align: "",
  },
  {
    prop: "project_name",
    label: "项目名称",
    width: "",
    minWidth: "300",
    align: "",
  },
  {
    prop: "invest_type",
    label: "投资类型",
    width: "",
    minWidth: "100",
    align: "",
  },
  {
    prop: "industry_value",
    label: "行业分类",
    width: "",
    minWidth: "100",
    align: "",
  },
  {
    prop: "investment",
    label: "总投资",
    width: "",
    minWidth: "100",
    align: "",
  },
  {
    prop: "status_text",
    label: "审核状态",
    width: "",
    minWidth: "80",
    align: "",
  },
  {
    prop: "create_user_name",
    label: "上报人",
    width: "",
    minWidth: "100",
    align: "",
  },
  {
    prop: "create_time",
    label: "上报时间",
    width: "150",
    minWidth: "",
    align: "",
  },
];
</script>

<style lang="scss" scoped>
</style>